<template>
  <div>
    <div>
      用户名: <input type="text" v-model="user.username"/>
    </div>
    <div>
      密码: <input type="password" v-model="user.password"/>
    </div>
    <div>
      <button type="button" @click="doLogin">登录</button>
    </div>

  </div>
</template>

<script>
  export default {
    name: 'Login',
    data () {
      return {
        user: {
          username: "",
          password: ""
        }
      }
    },
    methods: {
      doLogin () {
        this.axios.post("/login", {
          username: this.user.username,
          password: this.user.password
        }).then(res => {
          console.log(res);
          this.$router.replace("/")
        });
      }
    }
  }
</script>

<style scoped>

</style>
